#!/usr/bin/perl -w
use strict;
use Bio::SeqIO;

# db is the protein database
# match proteins - list of ones NOT to print out their length
my ($db,$match) = @ARGV;


my %skip_proteins;

open(my $fh => $match) || die "cannot open $match: $!\n";
my $header = <$fh>;
# parse the match file
while(<$fh>) {
    my ($name) = split;
    $skip_proteins{$name}++;
}
close($fh);

# parse the original protein database sequence file (all the proteins in genome)
my $in = Bio::SeqIO->new(-format => 'fasta',
			 -file   => $db);
# print the header
print join("\t", qw(PROTEIN_NAME LENGTH)),"\n";
while(my $seq = $in->next_seq ) {
    my $name = uc $seq->display_id;
    if( $skip_proteins{$name} ) {
	next;
    }
    # only print sequence name and length for proteins that ARE NOT in the match file
    print join("\t", $name, $seq->length), "\n";    
}
